$(function() {
	//显示菜单信息
	var head = $("#breadcrumbs");
	head.html('<ul class="breadcrumb">' +
		'<li><i class="icon-home"></i> <a href="/">首页</a><span class="divider"><i class="icon-angle-right"></i></span></li>' +
		'<li><a href="#">统计分析</a> <span class="divider"><i class="icon-angle-right"></i></span></li>' +
		'<li><a href="/statistics">汇总查询</a><span class="divider"><i class="icon-angle-right"></i></span></li>' +
		'<li class="active">员工绩效确认</li></ul>');
	$.ajax({
		url: '/api/role/user?',
		type: 'GET',
		data: {'_t': new Date().getTime()},
		success: function(data) {
			for (var i = 0; i < data.length; i++) {
				if (data[i].roleName == '部门经理') {
					$.ajax({
						url: '/api/organizations/selOrgByUser?',
						type: 'GET',
						data: {'_t': new Date().getTime()},
						success: function(data) {
							// console.info("部门经理负责机构id：", data[0]);
							// 只有部门经理才能确定或者退回绩效
							for (var i = 0; i < data.length; i++) {
								if (perfDeprId == data[i].id&&perfState==1) {
									$('#weight').removeAttr('readonly', 'true');
									$('#return').attr('style', 'display:true');
									$('#surePer').attr('style', 'display:true');
								}
							}
						},
						error: function(data) {
							alert('error');
						}
					});
				}

			}
			//console.info(flag);
			// if (flag) {
			// 	$('#weight').attr('readonly', 'true');
			// 	$('#return').attr('style', 'display:none');
			// 	$('#surePer').attr('type', 'hidden');
			// 	$('#saveBtn').attr('type', 'hidden');
			// } else {
			// 	$('#weight').removeAttr('readonly', 'true');
			// 	$('#return').removeAttr('style', 'display:none');
			// 	$('#surePer').removeAttr('type', 'hidden');
			// 	$('#saveBtn').removeAttr('type', 'hidden');
			// }
		},
		error: function(data) {
			alert('error');
		}
	});

	$("#count").click(function() {
		var data = buildModel();
		// console.info(isNaN(data.score));
		var score = data.score;
		var level = data.level;
		// alert(score);
		$("#perfScore").html(score);
		$("#perfLevel").html(level);
	});

	$("#pluse_btnadd").click(function() {

		var template = "<tr><td class='span3' style='text-align:center;width:40%;word-wrap:break-word;vertical-align:middle;'>" +
			"<input type='text' id='pluse_term' name='pluse_term'  class='perAdd-input' onfocus=\"javascript:this.style.background='#FFFFFF';\" onblur=\"javascript:this.style.background='transparent';\"/></td>" +
			"<td class='span3' style='text-align:center;width:40%;word-wrap:break-word;vertical-align:middle;'>" +
			"<input type='text' id='pluse_content' name='pluse_content'  class='perAdd-input'  onfocus=\"javascript:this.style.background='#FFFFFF';\" onblur=\"javascript:this.style.background='transparent';\"/></td>" +
			"<td class='span2 hidden-480' style='text-align:center;width:10%;word-wrap:break-word;vertical-align:middle;'>" +
			"<input type='text' id='pluse_score' name='pluse_score'  class='perAdd-input'onfocus=\"javascript:this.style.background='#FFFFFF';\" onblur=\"javascript:this.style.background='transparent';\" /></td>" +
			"</tr>";
		// var $html = $(Mustache.to_html(template, null));
		$("#tbd_pluse").append(template);
		document.onclick = function() {
			var obj = event.srcElement;
			// console.info(obj.id);
			if (obj.id == "pluse_deleteIcon") {
				obj = obj.parentNode.parentNode;
				// console.log(obj);
				obj.remove();
			}
		}
	});

    var http = new XMLHttpRequest;
    http.open("HEAD", ".", false);
    http.send(null);
    var today = new Date(http.getResponseHeader("Date"));
    var year_today = today.getFullYear();
    var month_today = (today.getMonth() + 1) < 10 ? "0" + (today.getMonth() + 1) : (today.getMonth() + 1);
	var day = today.getDate() < 10 ? "0" + today.getDate() : today.getDate();

	//点击返回按钮
	$("#goBack").click(function() {
		// window.history.back();
		var hisPage = $("#hisPage").val();
		var key = $("#getKey").val();
		window.location.href = "/statistics?hisPage=" + hisPage + "&key=" + encodeURIComponent(key);
	});
	var perfDeprId;
	var perfState;
	var init = function() {
		// $("#hideTr1").css("display","block");
		// $("#hideTr2").css("display","block");
		var perfId = $("#getPerfId").val();
		$.ajax({
			url: '/api/performance_term/' + perfId + '?',
			type: 'get',
			data: {'_t': new Date().getTime()},
			success: function(data) {
				// console.info('data', data);
				if (data != null && data.perfData != null && data.perfData.length != 0) {
					var perfData = data.perfData;
					perfDeprId = perfData.departmentId;
					perfState=perfData.state
					var termsData = data.termsData;
					showBasic(perfData);
					// $("#perfDate").val(perfData.perfDate);
					// $("#employee").val(perfData.empName);
					// $("#employeeid").val(perfData.employeeId);
					// $("#assessmentid").val(perfData.assessmentPersonId);
					// $("#assessmentPerson").val(perfData.assName);
					// $("#comment").val(perfData.comment);
					// if (perfData.state != 0) {
						
					// 	$("#perfScore").html(Math.round(perfData.score * 100) / 100);
					// 	$("#perfLevel").html(perfData.level);
					// }

					var zhiyehua = [];
					for (var i = 0; i < termsData.length; i++) {
						if (termsData[i].type == 2) {
							zhiyehua.push(termsData[i]);
						}
					}
					// getOrgParents(perfData.departmentId, 0);
					// if (perfData.preDeptId != null) {
						
					// 	$("#preDeptId").val(perfData.preDeptId);
					// 	getOrgParents(perfData.preDeptId, 1)
					// }
					// if (perfData.project != null) {
					// 	$("#project").val(perfData.project);
					// }
					showTerms(termsData, perfData.state);
					//------------去掉重复的考核人-------
					var yinchang = function() {
						var $label = $('#returnBack').find("label");
						//拿到选取的审核人
						var idss = [];
						$.each($label, function(i, element) {
							var id = $(element).find('#assperson').val(); //勾选的考核人id
							// console.info('ididid', id);
							idss.push(id);
						});
						for (var i = 0; i < idss.length; i++) {
							var count = document.getElementsByName(idss[i]).length;
							for (var m = 1; m < count; m++) {
								document.getElementsByName(idss[i])[m].style.display = "none";
							}
						}
					}
					yinchang();

					//-----------------------------------

					$('#surePer').click(function() {
						var perfId = $("#getPerfId").val();
						var comment = $("#comment").val();
						var array = [];
						array.push(perfId);
						var data = {
							ids: array,
							comment: comment
						}
						// console.info('hello', data);
						// return;
						if (perfData.state == 0) {
							bootbox.alert('该绩效还未被审核完,不能确认！');
							return;
						}
						if (perfData.state == 2) {
							bootbox.alert('该绩效已被确认！');
							return;
						}
						if(comment.length > 120) {
							bootbox.alert('总体评价过长！');
							return;
						}
						data.operation = "确认";
						$.ajax({
							url: '/api/performance/state',
							type: 'put',
							data: data,
							success: function(result) {
								//console.info('hahah', result);
								if (result == 'noPrivilege') {
									bootbox.alert('您没有权限,操作失败！');
									return;
								}
								bootbox.alert(result, function() {
									var hisPage = $("#hisPage").val();
									window.location.href = "/statistics?hisPage=" + hisPage;
									// window.location.href = document.referrer;
								});
							},
							error: function(result) {
								bootbox.alert('确认失败！');
							}
						});
					});

					$('#return').click(function() {
						if(day < 23 || day > 26) {
							if(data.access != "退回") {
								bootbox.alert("绩效审核期内（23-26号）才能退回绩效！");
								return;
							}
							// bootbox.alert("绩效审核期内（23-26号）才能退回绩效！");
							// return;
						}
						var itemsData = [];

						for (var i = 0; i < termsData.length; i++) {
							if (termsData[i].type == 0) {
								itemsData.push(termsData[i]);
							}
						}

						var sendDataaa = [];
						var total = 0;
						for (var i = 0; i < itemsData.length; i++) {
							var weight = $("#tbd_task tr:eq(" + i + ") td:eq(2) input:eq(0)").val();
							var id = $("#tbd_task tr:eq(" + i + ") input:eq(0)").val();
							var dd = {
								weight: parseFloat(weight),
								id: id
							};
							total += parseFloat(weight) * 1;
							sendDataaa.push(dd);
						}
						// console.info('total', total);
						if (total != 100) {
							bootbox.alert('权重之和不等于100！');
							return;
						}
						//console.info('hahahhahah',sendDataaa);
						var sendData = {
							'data': sendDataaa
						};

						$.ajax({
							url: '/api/performance_term',
							type: "put",
							data: sendData,
							success: function(result) {
								if (result == 'noPrivilege') {
									bootbox.alert('您没有权限,操作失败！');
									return;
								}
								returnBack();

							},
							error: function(result) {
								bootbox.alert("绩效信息保存失败！");
							}
						});
					});


					var returnBack = function() {
						var perfId = $('#getPerfId').val();
						var $label = $('#returnBack').find("label");
						var ids = [];
						//拿到选取的审核人
						$.each($label, function(i, element) {
							var checked = $(element).find('input').is(':checked');
							if (checked) { //如果有一个把勾选，就把name同名的所有都勾选
								var assId = $(element).find('#assperson').val(); //勾选的考核人id
								var label = document.getElementsByName(assId);
								for (var i = 0; i < label.length; i++) {
									$(label[i]).find('input').attr("checked", "checked");
								}
							}

							if (checked) {
								var termId = $(element).find('#termId').val(); //绩效项id
								var id = $(element).find('#assperson').val(); //勾选的考核人id
								// console.info('ididid', id);
								ids.push(termId);
								for (var i = 0; i < zhiyehua.length; i++) {
									if (id == zhiyehua[i].assPersonId * 1) {
										ids.push(zhiyehua[i].id);
									}
								}
							}

						});
						// console.info('ids',ids);
						// return;
						var returnReason = $('#comment').val();
						//todo... 获取退回绩效项的id（数组）
						var data = {
							id: perfId,
							reason: returnReason,
							termId: ids,
							operation: "退回" //绩效项id数组
						};

						if (returnReason.trim() == '' || returnReason.trim() == null || returnReason.trim() == undefined) {
							$("#msg").css("display", "block");
							$("#msgtitle").html('请填写总体评价,指明退回原因');
							return;
						}
						if(returnReason.length > 120) {
							bootbox.alert("退回原因过长！");
							return;
						}
						if (data.termId == [] || data.termId.length == 0) {

							$("#msg").css("display", "block");
							$("#msgtitle").html('请勾选退回考核人');
							return;
						}
						if (perfData.state == 0) {
							bootbox.alert('该绩效未被审核，不能退回！');
							return;
						}
						if (perfData.state == 2) {
							bootbox.alert('该绩效已被确认,不能退回！');
							return;
						}

						$.ajax({
							url: '/api/performance/return',
							type: 'put',
							data: data,
							success: function(result) {
								if (result == 'noPrivilege') {
									bootbox.alert('您没有权限,操作失败！');
									return;
								}
								bootbox.alert(result, function() {
									var hisPage = $("#hisPage").val();
									window.location.href = "/statistics?hisPage=" + hisPage;
									// window.location.href = document.referrer;
								});
							},
							error: function(result) {
								bootbox.alert('退回失败！');
							}
						});
					}
				} else {
					return;
				}
				// 如果员工属于后勤支持体系，则员工绩效占比为20%
				getSysName(perfData.departmentId);
				if (data.logData != null && data.logData != "") {
					// alert(data.logData);
					showLogs(data.logData);
					$("#logTab").css("display", "block");
				}
			}
		});
		
		

	};

	init();
	var showBasic = function(perfData) {
		$("#perfDate").val(perfData.perfDate);
		$("#employee").val(perfData.empName);
		$("#employeeid").val(perfData.employeeId);
		$("#assessmentid").val(perfData.assessmentPersonId);
		$("#assessmentPerson").val(perfData.assName);
		$("#comment").val(perfData.comment);
		if (perfData.state != 0) {
			
			$("#perfScore").html(Math.round(perfData.score * 100) / 100);
			$("#perfLevel").html(perfData.level);
		}else{
			$("#perfScore").html('0');
			$("#perfLevel").html('E');
		}
		getOrgParents(perfData.departmentId, 0);
		if (perfData.preDeptId != null) {
			
			$("#preDeptId").val(perfData.preDeptId);
			getOrgParents(perfData.preDeptId, 1)
		}
		if (perfData.project != null) {
			$("#project").val(perfData.project);
		}
	};
	var showTerms = function(termsData, perfState) {
		if (termsData != null && termsData.length != 0) {
			$("#tbd_task").html('');
			if (perfState == 1) {
				$("#tbd_pluse").html('');
				$("#tbd_professional").html('');
			}
			var showPluseFlag=true;
			var showProfessionalFlag=true;
			$.each(termsData, function(i, item) {
				// console.info(i + "-----", item.completion);
				var templateData = {
					term: item.term,
					termId: item.id,
					content: item.content,
					weight: item.weight + "%",
					completion: item.completion,
					score: item.score,
					name: item.name,
					assPersonId: item.assPersonId
				};
				var template;


				if (item.type == 0) {
					//工作事项

					var returnTemplate = "<label style='margin:6px' name={{assPersonId}}><input type=checkbox id='termId' value={{termId}}><span class=lbl style='padding-bottom:6px'></span><input type=hidden id='assperson' value={{assPersonId}}><span id='assName'>{{name}}</span></label>&nbsp;&nbsp;&nbsp;";
					var $returnHtml = $(Mustache.to_html(returnTemplate, templateData));
					$("#returnBack").append($returnHtml);

					template = "<tr><input type='hidden' id=termId name=termId value='{{termId}}'><td class=span3 style='width:20%;word-wrap:break-word;vertical-align:middle; text-align:center' id=term name=term>{{term}}</td>" +
						"<td class='span3' style='width:30%;word-wrap:break-word;vertical-align:middle; text-align:center' id=content name=content>{{content}}</td>" +
						"<td class='span2 hidden-480' style='width:10%;word-wrap:break-word;vertical-align:middle; text-align:center'  name=weight ><input type='text' id=weight name='weightsss' class='perAdd-input'  style='padding:0px 0px' onfocus=\"javascript:this.style.background='#FFFFFF';\" onblur=\"javascript:this.style.background='transparent';\" value='{{weight}}' readonly=true></td>" +
						"<td class='span3 hidden-phone' style='width:20%;word-wrap:break-word;vertical-align:middle; text-align:center' id='completion' name='completion'>{{completion}}</td>" +
						"<td class='span2 hidden-480' style='width:10%;word-wrap:break-word;vertical-align:middle; text-align:center' id='score' name='score'>{{score}}</td>" +
						"<td class='span2 hidden-480' style='width:10%;word-wrap:break-word;vertical-align:middle; text-align:center' id='assName' name='assName' >{{name}}</td></tr>";
					var $html = $(Mustache.to_html(template, templateData));
					$("#tbd_task").append($html);

				} else if (item.type == 1) {
					showPluseFlag=false;
					template = "<tr><input type='hidden' id=pluse_termId name=pluse_termId value='{{termId}}'><td class='span3' style='text-align:center;width:40%;word-wrap:break-word;vertical-align:middle;' id='pluse_term' name='pluse_term'>{{term}}</td>" +
						"<td class='span3' style='text-align:center;width:40%;word-wrap:break-word;vertical-align:middle;' id='pluse_content' name='pluse_content'>{{content}}</td>" +
						"<td class='span2 hidden-480' style='text-align:center;width:10%;word-wrap:break-word;vertical-align:middle;' id='pluse_score' name='pluse_score'> {{score}}</td>" +
						"<td class='span2' style='text-align:center;width:10%;word-wrap:break-word;vertical-align:middle;' id='pluse_name' name='pluse_score'>{{name}}</td>" +
						"</tr>";

					var $html = $(Mustache.to_html(template, templateData));
					$("#tbd_pluse").append($html);
				} else if (item.type == 2) {
					showProfessionalFlag=false;
					template = "<tr><input type=hidden id=professional_termId name=professional_termId value='{{termId}}'><td class='span3' style='text-align:center;width:30%;word-wrap:break-word;vertical-align:middle;' id='professional_term' name='professional_term'>{{term}}</td>" +
						"<td class='span3' style='text-align:center;width:10%;word-wrap:break-word;vertical-align:middle;' id='professional_weight' name='professional_weight'>{{weight}}</td>" +
						"<td class='span2 hidden-480' style='text-align:center;width:40%;word-wrap:break-word;vertical-align:middle;' id='professional_completion' name='professional_completion'>{{completion}}</td>" +
						"<td class='span2 hidden-480' style='text-align:center;width:10%;word-wrap:break-word;vertical-align:middle;' name='professional_score' id='professional_score'>{{score}}</td></tr>";


					var $html = $(Mustache.to_html(template, templateData));
					$("#tbd_professional").append($html);
				}
			});
			if(showPluseFlag){
				$("#pluseDiv").remove();
			}
			if(showProfessionalFlag){
				$("#professionalDiv").remove();
			}
			
		} else {
			return;
		}

	};
	var showLogs = function(logData) {
		// console.info("logData", logData);
		$("#tbd_log").html('');
		$.each(logData, function(i, item) {
			// alert(item.updateDate);
			var templateData = {
				logId: item.id,
				name: item.name,
				updateDate: item.updateDate,
				operation: item.operation
			};
			var template = "<tr><td class='center'>{{name}}<input type=hidden id=logId value={{logId}}></td><td class='center'>{{updateDate}}</td><td class='center'>{{operation}}</td></tr>";
			var $html = $(Mustache.to_html(template, templateData));
			$html.click(function() {
				// window.location.href = "/api/log/" + item.id;
				$.ajax({
					url: "/api/log/" + item.id,
					type: "get",
					success: function(logData) {
						// console.info(logData);
						$("#tbd_task").html('');
						$("#tbd_pluse").html('');
						$("#tbd_professional").html('');
						$("#perfScore").html('0');
						$("#perfLevel").html('E');
						
						$("#logTab").removeClass("active");
						$("#log").removeClass("active");
						$("#demo").addClass("active");
						// $("#demo").html("<a data-toggle='tab' href='#performanceInfo'> <i class='green icon-info-sign bigger-110'></i>详细历史信息</a>");
						$("#performanceInfo").addClass("active");
						$("#hideTr1").css("display","none");
						$("#hideTr2").css("display","none");
						$('#weight').attr('readonly', 'true');
						$('#return').css("display","none");
						$('#surePer').css("display","none");
						if(logData != null && logData.content.perfData != null) {
							showBasic(logData.content.perfData);
							if(logData.content.termsData != null) {
								showTerms(logData.content.termsData, logData.content.perfData.state);
							}
							
						}
					}
				});
			});
			$("#tbd_log").append($html);
		});
	};


	var getOrgParents = function(orgId, type) {
		$.ajax({
			url: '/api/organizations/getParents/' + orgId + '?',
			type: 'get',
			data: {'_t': new Date().getTime()},
			success: function(result) {
				// console.info(result);
				var parentString = "";
				for (var i = result.length - 1; i >= 0; i--) {
					if (i != 0) {
						if (result[i].orgName == "分公司") {
							continue;
						} else {
							parentString += result[i].orgName + "/";
						}

					} else {
						parentString += result[i].orgName;
					}
				}
				if (type == 1) {
					$("#projectDept").val(parentString);
					$("#preDeptId").val(result[0].id);
				} else {
					$("#department").val(parentString);
					$("#deptId").val(result[0].id);
				}


			}
		});
	};
	var getSysName=function(orgId) {
		$.ajax({
			url: '/api/organizations/getSysName/' + orgId + '?',
			type: 'get',
			data: {'_t': new Date().getTime()},
			success: function(result) {
				if(result.sysName=="后勤支持体系"){
					$("#salRadio").html("20%");
				}
			}
		});
	};

	// var buildModel = function() {
	// 	var assessmentPersonId = $("#assessmentid").val(); //考核人id
	// 	var assessmentPer = $("#assessmentPerson").val(); //考核人姓名
	// 	var employeeId = $("#employeeid").val(); //被考核人id
	// 	var employee = $("#employee").val(); //被考核人姓名
	// 	var perfDate = $("#perfDate").val(); //审核时间
	// 	var departmentId = $("#deptId").val();
	// 	var comment = $("#comment").val();
	// 	var preDeptId = $("#preDeptId").val();
	// 	var project = $("#project").val();
	// 	// console.info("comment:",$("#comment").val());

	// 	var basicItems = []; //新增绩效项
	// 	var updateItems = []; //更新绩效项
	// 	var perfScore = 0;
	// 	var basicScore = 0;
	// 	var professionalScore = 0;
	// 	var plusScore = 0;

	// 	// var sumWeight_professonal = 0;

	// 	//工作事项
	// 	var termArr = $("td[name='term']");
	// 	var contentArr = $("td[name='content']");
	// 	var weightArr = $("td[name='weight']");
	// 	var termIdArr = $("input[name='termId']");
	// 	var completionArr = $("input[name='completion']");
	// 	var scoreArr = $("input[name='score']");
	// 	termArr.each(function(i) {
	// 		var score = $(scoreArr[i]).val();
	// 		var weight = $(weightArr[i]).html().trim();
	// 		var itemData = {
	// 			termId: $(termIdArr[i]).val(),
	// 			term: $(termArr[i]).html().trim(),
	// 			content: $(contentArr[i]).html().trim(),
	// 			weight: weight,
	// 			completion: $(completionArr[i]).val(),
	// 			score: score,
	// 			type: 0
	// 		};
	// 		basicScore += parseFloat(score) * parseFloat(weight) / 100;
	// 		updateItems.push(itemData);
	// 	});

	// 	//加分项
	// 	var plus_termArr = $("input[name='pluse_term']");
	// 	var plus_contentArr = $("input[name='pluse_content']");
	// 	var plus_termIdArr = $("input[name='pluse_termId']");
	// 	var plus_scoreArr = $("input[name='pluse_score']");

	// 	plus_termArr.each(function(i) {
	// 		var plus_term = $(plus_termArr[i]).val();
	// 		if (plus_term != null && plus_term != "") {
	// 			var plusItem = {
	// 				term: $(plus_termArr[i]).val(),
	// 				content: $(plus_contentArr[i]).val(),
	// 				score: $(plus_scoreArr[i]).val(),
	// 				type: 1
	// 			};
	// 			plusScore += parseFloat($(plus_scoreArr[i]).val());
	// 			var plus_termId = $(plus_termIdArr[i]).val();
	// 			if (plus_termId != null && plus_termId != "") {
	// 				plusItem.termId = plus_termId;
	// 				updateItems.push(plusItem);
	// 			} else {
	// 				basicItems.push(plusItem);
	// 			}
	// 		}


	// 	});

	// 	//内容及标准
	// 	var professional_termArr = $("td[name='professional_term']");
	// 	var professional_weightArr = $("td[name='professional_weight']");
	// 	var professional_termIdArr = $("input[name='professional_termId']");
	// 	var professional_completionArr = $("input[name='professional_completion']");
	// 	var professional_scoreArr = $("input[name='professional_score']");
	// 	// console.info("professional_termIdArr:",professional_termIdArr);

	// 	professional_termArr.each(function(i) {
	// 		var professional_weight = $(professional_weightArr[i]).html().trim();
	// 		var professional_score = $(professional_scoreArr[i]).val();
	// 		var professionalItem = {
	// 			term: $(professional_termArr[i]).html().trim(),
	// 			weight: professional_weight,
	// 			completion: $(professional_completionArr[i]).val(),
	// 			score: professional_score,
	// 			type: 2
	// 		};
	// 		// sumWeight_professonal += professional_weight;
	// 		professionalScore += parseFloat(professional_score) * parseFloat(professional_weight) / 100;

	// 		var professional_termId = $(professional_termIdArr[i]).val();
	// 		// console.info("professional_termId:",professional_termId);
	// 		if (professional_termId != null && professional_termId != "") {
	// 			professionalItem.termId = professional_termId;
	// 			updateItems.push(professionalItem);
	// 		} else {
	// 			basicItems.push(professionalItem);
	// 		}
	// 	});
	// 	//加分项总和不能超过20分
	// 	if (plusScore > 20) {
	// 		plusScore = 20;
	// 	}
	// 	// console.info("basicScore=" + basicScore + "--plusScore=" + plusScore + "--professionalScore=" + professionalScore);
	// 	perfScore = (basicScore * 0.7) + plusScore + (professionalScore * 0.3);
	// 	var level = "";
	// 	if (perfScore >= 100) {
	// 		level = "A";
	// 	} else if (perfScore >= 85 && perfScore < 100) {
	// 		level = "B";
	// 	} else if (perfScore >= 75 && perfScore < 85) {
	// 		level = "C";
	// 	} else if (perfScore >= 60 && perfScore < 75) {
	// 		level = "D";
	// 	} else {
	// 		level = "E";
	// 	}

	// 	var performanceData = {
	// 		basicItems: basicItems,
	// 		updateItems: updateItems,
	// 		assessmentPersonId: assessmentPersonId,
	// 		employeeId: employeeId,
	// 		perfDate: perfDate,
	// 		departmentId: departmentId,
	// 		score: Math.round(perfScore * 100) / 100,
	// 		level: level,
	// 		comment: comment,
	// 		state: 1,
	// 		preDeptId: preDeptId,
	// 		project: project
	// 	};


	// 	return performanceData;
	// };

	//定义取小数点后两位函数

	function changeTwoDecimal(x) {
		var f_x = parseFloat(x);
		if (isNaN(f_x))
			return false;
		var f_x = Math.round(x * 100) / 100;
		var s_x = f_x.toString();
		var pos_decimal = s_x.indexOf('.');
		if (pos_decimal < 0) {
			pos_decimal = s_x.length;
			s_x += '.';
		}
		while (s_x.length <= pos_decimal + 2) {
			s_x += '0';
		}
		return s_x;
	}

});